package com.坦克大战.Tank_2;

public class Shoot extends Thread {
    int x;
    int y;
    int direction;
    int speed = 10;
    boolean isLive = true;

    public Shoot(int x, int y, int direction) {
        this.x = x;
        this.y = y;
        this.direction = direction;
    }

    @Override
    public void run() {
        while (true) {
            switch (direction) {
                case 0:
                    y -= speed;
                    break;
                case 1:
                    x -= speed;
                    break;
                case 2:
                    y += speed;
                    break;
                case 3:
                    x += speed;
                    break;
            }
            System.out.println("x: " + x + " y: " + y);
            if (x >= 2000 || x <= 0 || y >= 1000 || y <= 0) {
                System.out.println("子弹销毁");
                isLive = false;
                break;
            }

            try {
                sleep(50);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }


}
